package cn.ehanghai.htz.controller;

import cn.ehanghai.htz.common.constants.ReturnCode;
import cn.ehanghai.htz.domain.ServiceInfo;
import cn.ehanghai.htz.service.ServiceInfoService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

/**
 * @Author: xumf
 * @Date: 2019/7/18 18:06
 */
@RequestMapping("/service")
@RestController
@CrossOrigin
public class ServiceController {

    @Autowired
    private ServiceInfoService serviceInfoService;

    /**
     * 设置IP和端口
     */
    @RequestMapping("/set")
    public ReturnCode setServiceInfo(@RequestParam(name = "ip") String ip, @RequestParam(name = "port") Integer port){
        ServiceInfo serviceInfo=new ServiceInfo();
        serviceInfo.setServerIp(ip);
        serviceInfo.setPort(port);
        serviceInfoService.insert(serviceInfo);
        return ReturnCode.success();
    }
}
